package com.example.monitoringsystem.controller;

import com.example.monitoringsystem.bean.Medicine;
import com.example.monitoringsystem.service.MedicineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class MedicineController {
    @Autowired
    private MedicineService medicineService;

    //显示药物
    @GetMapping("/medicine")
    @ResponseBody
    public List<Medicine> showAllMedicine(){
        List<Medicine> medicines = medicineService.showAllMedicine();
        if (medicines != null){
            return medicines;
        }
        else {
            System.out.println("药物库为空");
            return null;
        }
    }
}
